var express = require('express');
var router = express.Router();
const jwt = require('jsonwebtoken');

router.post('/token', function (req, res) {
    // 解密返回用户数据
    //解密 会把token生成时传入的用户信息解密出来
    const token = req.get('Authorization').split(' ')[1];
    const user = jwt.verify(token, 'user');
    res.send({
        message: '验证成功',
        code: 200,
        user: user
    });
});

module.exports = router;
